﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IceDog.DNF.Program.WinForm
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void TimerDatetime_Tick(object sender, EventArgs e)
        {
            var d = DateTime.Now;
            var text = $"当前时间：{d.Year}年{FillZero(d.Month)}月{FillZero(d.Day)}日" +
                $"{FillZero(d.Hour)}点{FillZero(d.Minute)}分{FillZero(d.Second)}.{FormatMs(d.Millisecond)}秒";
            toolStripStatusLabelDatetime.Text = text;
        }
        private string FillZero(int num) => num < 10 ? $"0{num}" : num.ToString();
        private string FormatMs(int num)
        {
            if (num > 99)
            {
                num = (int)Math.Floor(num / 10D);
            }
            return FillZero(num);
        }
    }
}
